package cn.china.springboot.serviceimpl;

import entity.User;
import mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

@Service
public class UserServiceImpl {
    @Autowired
    UserMapper um;

    /**
     * 登录
     * @param username
     * @param password
     * @return
     */
    public String Login(String username,String password) {
        User u1 =  um.selectUserByName(username,password);
        if (u1 == null) {
            return "no";
        } else {
            return "yes";
        }
    }

    /**
     * 注册
     * @param username
     * @param password
     * @param phone
     * @return
     */
    public String register(String username, String password, String phone) {

        User user1 = um.selectUserByName(username,password);
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setPhone(phone);
        if (user1 == null) {
            um.insert(user);
            return "ok";
        } else {
            return "noway";
        }
    }
}
